package com.webull.information.center.carwler.task.support;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webull.information.center.carwler.common.model.StockConfig;
import com.webull.information.center.carwler.common.model.StockTitle;
import com.webull.information.center.carwler.dao.StockConfigDao;
import com.webull.information.center.carwler.validator.StockerConfigValidator;

@Service
public class StockConfigSupport {
	protected final Logger logger = LogManager.getLogger(getClass());
	private @Autowired StockConfigDao stockConfigDao;
	private @Autowired StockerConfigValidator stockerConfigValidator;

	public StockConfig getStockConfig(StockTitle title, String collectSource, String lang) {
		stockerConfigValidator.validateStockTitle(title);
		return stockConfigDao.getBySource(title, collectSource, lang);
	}

	public StockConfig getByTarget(Integer targetId, String collectSource, String lang) {
		stockerConfigValidator.validateGetById(targetId);
		return stockConfigDao.getByTarget(targetId, collectSource, lang);
	}
	public void updateById(StockConfig stockConfig) {
		stockerConfigValidator.validateObjectIsNull(stockConfig);
		stockConfigDao.updateById(stockConfig);
	}
}
